package com.jiezheng.huinong.action;

import java.io.InputStream;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class DownloadAction extends ActionSupport {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 3009073579460802241L;

	private String fileName;

	private static final String TMPLATE_PATH = "template/";

	public InputStream getInputStream() {
		setFileName(fileName);
		return ServletActionContext.getServletContext().getResourceAsStream(
				"/" + TMPLATE_PATH + fileName);
	}

	public String execute() {
		return SUCCESS;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFileName() {
		return fileName;
	}
}
